#ifndef BASEDATA_H
#define BASEDATA_H
#include <memory>
#include <type_traits>
#include <mutex>
#include <utility>
#include <string>
#include <list>
template<typename T>
class BaseData
{
public:
    BaseData(const BaseData&)=delete;
    BaseData& operator=(const BaseData&) = delete;
    BaseData(BaseData&)=delete;
    BaseData& operator=(BaseData&&)=delete;

public:
    // 主获取方法
    static T& getInstance() {
        return *getInstancePtr();
    }

    // 获取指针版本
    static T* getInstancePtr() {
        static_assert(std::is_default_constructible<T>::value ||
                          std::is_constructible<T>::value,
                      "T must be constructible");
        return &instance;
    }
    // 模板方法支持 - 在实例上调用成员函数
    template<typename Func, typename... Args>
    static auto execute(Func&& func, Args&&... args)
        -> decltype((getInstance().*func)(std::forward<Args>(args)...)) {
        return (instance.*func)(std::forward<Args>(args)...);
    }

    // 类型信息
    using Type = T;
    static constexpr const char* name() { return typeid(T).name(); }
protected:
    BaseData()=default;
    virtual ~BaseData()=default;

private:
   inline static T instance;
};

#endif // BASEDATA_H
